home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7192 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.6 KB  |  93 lines

  1. Path: mother.usf.edu!news
  2. From: yatesc@csee.usf.edu (Randy Yates)
  3. Newsgroups: comp.lang.c++
  4. Subject: Specifying a Member Function Address For WNDCLASS Structure
  5. Date: 22 Feb 1996 05:16:04 GMT
  6. Organization: University of South Florida
  7. Message-ID: <4ggu6k$5c1@mother.usf.edu>
  8. NNTP-Posting-Host: ppp53.cfr.usf.edu
  9. Mime-Version: 1.0
  10. X-Newsreader: WinVN 0.93.14
  11.  
  12. Hello,
  13.  
  14. I'm writing a MS-Windows 3.1 program and I'd like to have the
  15. message processing procedure for the window class be a member
  16. function, but Borland C++ 4.0 complains with a
  17.  
  18. Error GAMECON.CPP 25: Cannot convert 'long (pascal GameControl::*)(unsigned int,unsigned int,unsigned 
  19. int,long)' to 'long (pascal *)(unsigned int,unsigned int,unsigned int,long)'
  20.  
  21.  
  22. The definition goes something
  23. like this:
  24.  
  25. class GameControl
  26. {
  27.   private:
  28.     HWND hWnd; 
  29.   public:
  30.     GameControl(HINSTANCE, int);
  31.     long FAR PASCAL _export WndProc(HWND, UINT, UINT, long);
  32. };
  33.  
  34. GameControl::GameControl(HINSTANCE hInstance, int nCmdShow)
  35. {
  36. //  static char szAppName[] = "GameControl";
  37.   WNDCLASS wndclass;
  38.  
  39.   // Create the window:
  40.   wndclass.style            = CS_HREDRAW | CS_VREDRAW;
  41.   wndclass.lpfnWndProc      = &GameControl::WndProc;
  42.   wndclass.cbClsExtra       = 0;
  43.   wndclass.cbWndExtra       = 0;
  44.   wndclass.hInstance        = hInstance;
  45.   wndclass.hIcon            = LoadIcon(hInstance, "USF_Bull");
  46.   wndclass.hCursor          = LoadCursor(NULL, IDC_ARROW);
  47.   wndclass.hbrBackground    = GetStockObject(BLACK_BRUSH);
  48.   wndclass.lpszMenuName     = NULL;
  49.   wndclass.lpszClassName    = PINBULL_CLASSNAME;
  50.  
  51.   RegisterClass(&wndclass);
  52.  
  53.   hWnd = CreateWindow(
  54.            PINBULL_CLASSNAME,
  55.            "PinBull Wizard Game Control",
  56.            WS_OVERLAPPEDWINDOW,
  57.            CW_USEDEFAULT,
  58.            CW_USEDEFAULT,
  59.            CW_USEDEFAULT,
  60.            CW_USEDEFAULT,
  61.            HWND_DESKTOP,
  62.            NULL,
  63.            hInstance,
  64.            NULL);
  65.    
  66.   ShowWindow (hWnd, nCmdShow);
  67.   UpdateWindow (hWnd);
  68. }
  69.  
  70. long FAR PASCAL _export GameControl::WndProc(HWND hWnd, UINT message, UINT wParam, long lParam)
  71. {
  72.   switch (message)
  73.   {
  74.     case WM_DESTROY:
  75.       PostQuitMessage(0);
  76.       return 0;
  77.     break;
  78.     default:
  79.       return DefWindowProc(hWnd, message, wParam, lParam);
  80.     break;
  81.   }
  82. }
  83.  
  84. I would love to discuss this with anyone who has run into the same/similar
  85. problem and found a fix. 
  86.  
  87. -- 
  88. % Randy Yates                  % "...the answer lies within your soul
  89. % EE/Mathematics Student       %       'cause no one knows which side 
  90. % University of South Florida  %                   the coin will fall."
  91. % <yatesc@csee.usf.edu>        %  'Big Wheels', *Out of the Blue*, ELO   
  92.  
  93.